<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   design_blank
 * @package    Mage
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

/**
USAGE:

Simple:

<?php echo $this->getLayout()->createBlock('customer/widget_name')
   ->setObject($this->getAddress())
   ->toHtml() ?>

For checkout/onepage/shipping.phtml:

<?php echo $this->getLayout()->createBlock('customer/widget_name')
   ->setObject($this->getAddress())
   ->setFieldIdFormat('shipping:%s')
   ->setFieldNameFormat('shipping[%s]')
   ->setFieldParams('onchange="shipping.setSameAsBilling(false);"')
   ->toHtml() ?>
*/
?>

<div class="<?php echo $this->getContainerClassName()?>">
<?php if ($this->showPrefix()): ?>
    <div class="input-box name-prefix">
        <label for="<?php echo $this->getFieldId('prefix')?>">
            <?php echo $this->__('Prefix') ?>
            <?php if ($this->isPrefixRequired()):?><span class="required">*</span><?php endif; ?>
        </label>
        <br />
        <?php if ($this->getPrefixOptions()===false): ?>
        <input type="text" id="<?php echo $this->getFieldId('prefix')?>" name="<?php echo $this->getFieldName('prefix')?>" value="<?php echo $this->htmlEscape($this->getObject()->getPrefix()) ?>" title="<?php echo $this->__('Prefix') ?>" class="input-text <?php if ($this->isPrefixRequired()):?> required-entry<?php endif; ?>" <?php echo $this->getFieldParams() ?> />
        <?php else: ?>
        <select id="<?php echo $this->getFieldId('prefix')?>" name="<?php echo $this->getFieldName('prefix')?>" title="<?php echo $this->__('Prefix') ?>"<?php if ($this->isPrefixRequired()):?> class="required-entry"<?php endif; ?> <?php echo $this->getFieldParams() ?> />
        <?php foreach ($this->getPrefixOptions() as $_option): ?>
            <option value="<?php echo $_option?>"<?php if ($this->getObject()->getPrefix()==$_option):?> selected="selected"<?php endif; ?>><?php echo $this->__($_option)?></option>
        <?php endforeach ?>
        </select>
        <?php endif; ?>
    </div>
<?php endif; ?>

    <div class="input-box name-firstname">
        <label for="<?php echo $this->getFieldId('firstname')?>">
            <?php echo $this->__('First Name') ?>
            <span class="required">*</span>
        </label>
        <br />
        <input type="text" id="<?php echo $this->getFieldId('firstname')?>" name="<?php echo $this->getFieldName('firstname')?>" value="<?php echo $this->htmlEscape($this->getObject()->getFirstname()) ?>" title="<?php echo $this->__('First Name') ?>" class="input-text required-entry" <?php echo $this->getFieldParams() ?> />
    </div>

<?php if ($this->showMiddlename()): ?>
    <div class="input-box name-middlename">
        <label for="<?php echo $this->getFieldId('middlename')?>">
            <?php echo $this->__('M.I.') ?>
        </label>
        <br />
        <input type="text" id="<?php echo $this->getFieldId('middlename')?>" name="<?php echo $this->getFieldName('middlename')?>" value="<?php echo $this->htmlEscape($this->getObject()->getMiddlename()) ?>" title="<?php echo $this->__('M.I.') ?>" class="input-text" <?php echo $this->getFieldParams() ?> />
     </div>
<?php endif; ?>

    <div class="input-box name-lastname">
        <label for="<?php echo $this->getFieldId('lastname')?>">
            <?php echo $this->__('Last Name') ?>
            <span class="required">*</span>
        </label>
        <br />
        <input type="text" id="<?php echo $this->getFieldId('lastname')?>" name="<?php echo $this->getFieldName('lastname')?>" value="<?php echo $this->htmlEscape($this->getObject()->getLastname()) ?>" title="<?php echo $this->__('Last Name') ?>" class="input-text required-entry" <?php echo $this->getFieldParams() ?> />
    </div>

<?php if ($this->showSuffix()): ?>
    <div class="input-box name-suffix">
        <label for="<?php echo $this->getFieldId('suffix')?>">
            <?php echo $this->__('Suffix') ?>
            <?php if ($this->isSuffixRequired()):?><span class="required">*</span><?php endif; ?>
        </label>
        <br />
        <?php if ($this->getSuffixOptions()===false): ?>
        <input type="text" id="<?php echo $this->getFieldId('suffix')?>" name="<?php echo $this->getFieldName('suffix')?>" value="<?php echo $this->htmlEscape($this->getObject()->getSuffix()) ?>" title="<?php echo $this->__('Suffix') ?>" class="input-text<?php if ($this->isSuffixRequired()):?> required-entry<?php endif; ?>" <?php echo $this->getFieldParams() ?> />
        <?php else: ?>
        <select id="<?php echo $this->getFieldId('suffix')?>" name="<?php echo $this->getFieldName('suffix')?>" title="<?php echo $this->__('Suffix') ?>"<?php if ($this->isSuffixRequired()):?> class="required-entry"<?php endif; ?> <?php echo $this->getFieldParams() ?> />
        <?php foreach ($this->getSuffixOptions() as $_option): ?>
            <option value="<?php echo $_option?>"<?php if ($this->getObject()->getSuffix()==$_option):?> selected="selected"<?php endif; ?>><?php echo $this->__($_option)?></option>
        <?php endforeach ?>
        </select>
        <?php endif; ?>
    </div>
<?php endif; ?>
</div>
